﻿<Window x:Class="WpfTestApplication.ControlTemplateTestWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ControlTemplateTestWindow" Height="381" Width="432"  DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.Resources>
        <ControlTemplate TargetType="Button" x:Key="MyTemplate">
            <Border Name="RootElement">
                <Border.Background>
                    <SolidColorBrush x:Name="BorderBrush" Color="Gray"/>
                </Border.Background>
                <Grid Margin="4">
                    <ListBox Width="180" Height="60" Name="SomeAdditionalComponents">
                        <ListBoxItem>test1</ListBoxItem>
                        <ListBoxItem>
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </ListBoxItem>
                        <ListBoxItem>test2</ListBoxItem>
                    </ListBox>
                </Grid>
            </Border>
        </ControlTemplate>
        <ControlTemplate x:Key="MyTemplateToolTip">
            <StackPanel Height="100" Width="200">
                <StackPanel Height="30" Width="200" >
                    <TextBlock Height="30" Width="143">
                            <Run Text="Hello! Fancy Tip"/>
                    </TextBlock>
                </StackPanel>
                <StackPanel Width="200"  >
                    <TextBlock Width="200" Height="98">
                         <Run Text="The original ToolTip text is not shown here." />
                    </TextBlock>
                </StackPanel>
            </StackPanel>
        </ControlTemplate>

    </Window.Resources>
    <Grid>
        <Button Height="75" Margin="66,0,64,28" Name="fancyButton" VerticalAlignment="Bottom" Template="{StaticResource MyTemplate}" Click="button1_Click">
            Click me!
            <Button.ToolTip>
                <ToolTip Template="{StaticResource MyTemplateToolTip}">Tooltip</ToolTip>
            </Button.ToolTip>
        </Button>
        <Label Height="28" Margin="66,137,0,0" Name="label" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120">-</Label>
    </Grid>
</Window>
